home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / netzwerk / tcp-ip / netface-beta / bin / newsq.rexx < prev    next >
OS/2 REXX Batch file  |  1996-02-26  |  4KB  |  96 lines

  1. /*
  2.  * Scan the InetUtils SMTPd Queue directory, and show us what's going in
  3.  * where what's in the queue is going, and how long it's been there.
  4.  *
  5.  * Copyright  1994, Mike Meyer (mwm@contessa.phone.net)
  6.  adapted for PostNewsSpool :jb 30-Dec-94 (James Burton burton@cs.latrobe.edu.au)
  7.  */
  8.  
  9. /* Output tuning */
  10. queue_len = 20
  11. host_len = 40
  12.  
  13. /* Make sure we have the libraries */
  14. if ~show('Libraries', 'rexxarplib.library') then
  15.         if ~addlib('rexxarplib.library', 0, -30) then do
  16.                 say "No rexxarplib, so we can't scan the spool!"
  17.                 exit
  18.                 end
  19. if ~show('Libraries', 'rexxsupport.library') then
  20.         if ~addlib('rexxsupport.library', 0, -30) then do
  21.                 say "No rexxsupport library, so we can't scan the spool!"
  22.                 exit
  23.                 end
  24.  
  25. /* Get the SMTPSPoolDir */
  26. /*spooldir = getuuenv('SMTPSPOOLDIR')*/
  27. /*spooldir = getenv('SMTPSPOOLDIR')*/
  28. spooldir = "UUSPOOL:news"
  29. if spooldir = "" then do
  30.         say "Can't find the name of the directory to scan."
  31.         exit
  32.         end
  33. old = pragma('Directory', spooldir)
  34.  
  35. /* Get a list of files in it */
  36. count = filelist('msg???', files)
  37.  
  38. /* Now, process them */
  39. if count = 0 then
  40.         say "No articles in the news queue"
  41. else do
  42.         say left("Queue number", queue_len) ,
  43.                 || left("Destination newsgroup", host_len) || "Time in queue"
  44.         say ""
  45.         nowdays = date('Internal')
  46.         nowminutes = time('Minutes')
  47.         do i = 1 to count
  48.                 parse value files.i with 'msg'queue
  49.                 parse value statef(files.i) with . . . . filedays fileminutes .
  50.                 days = nowdays - filedays     
  51.                 /* now days is day difference */
  52.                 minutes = nowminutes - fileminutes
  53.                 /* minutes is minute difference */
  54.                 if minutes < 0 then do
  55.                     /* then it's 1 less day than we think */
  56.                         days = days /*+*/- 1
  57.                         minutes = minutes + 1440
  58.                         end
  59.                 hours = 24 * days + minutes % 60
  60.                 minutes = minutes // 60
  61.                 destination = getdestination(files.i)
  62.                 if destination = "" then iterate
  63.                 out = left(queue, queue_len) || left(destination, host_len)
  64.  
  65.                 select
  66.                         when hours = 0 & minutes = 0 then say out || "no time"
  67.                         when hours = 0 & minutes = 1 then say out || "1 minute"
  68.                         when hours = 0 then say out || minutes "minutes"
  69.                         when hours = 1 & minutes = 0 then say out || "1 hour"
  70.                         when hours = 1 & minutes = 1 then
  71.                                 say out || "1 hour 1 minute"
  72.                         when hours = 1 then
  73.                                 say out || "1 hour" minutes "minutes"
  74.                         when minutes = 0 then say out || hours "hours"
  75.                         when minutes = 1 then say out || hours "hours 1 minute"
  76.                         otherwise say out || hours "hours" minutes "minutes"
  77.                         end
  78.                 end
  79.         end
  80. say ""
  81. exit
  82.  
  83. getdestination: procedure
  84.         parse arg file
  85.  
  86.         if ~open(in, file, 'Read') then return ""
  87.         /* search for newsgroups line */
  88.         line = ""
  89.         do while (~eof(in)) & (left(line,11) ~= "Newsgroups:")
  90.             line = readln(in)
  91.         end
  92.         call close in
  93.         return substr(line,13)
  94.  
  95. /* end of file */
  96.